# 设置 CMake 最低版本
cmake_minimum_required(VERSION 2.8)

# 定义项目名称
project(server)

find_library(yaml yaml-cpp)
find_library(pthread-lib pthread)

include_directories(./src)
include_directories(${YAML_CPP_INCLUDE_DIR})

set(LIB_LIST ${pthread-lib} dl ${yaml})

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

# 定义库的源文件
set(SRC_LIST
    ${CMAKE_CURRENT_SOURCE_DIR}/src/base/config.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/src/base//Log.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/src/base/util.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/src/base/thread.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/src/base/mutex.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/src/base/fiber.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/src/base/scheduler.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/src/base/iomanager.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/src/base/timer.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/src/base/hook.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/src/base/fdmanager.cc
)

message(STATUS "--------SRC_LIST: ${SRC_LIST}--------LIB_LIST:${LIB_LIST}------YAML-cpp:${yaml}")
add_compile_options(-std=c++11 -Wall -g)
set (LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

add_library(serverLib STATIC ${SRC_LIST})
target_link_libraries(serverLib yaml-cpp ${LIB_LIST})

add_executable(test_log tests/test.cc)
target_link_libraries(test_log serverLib)

add_executable(test_config tests/configtest.cc)
target_link_libraries(test_config serverLib)


add_executable(test_thread tests/test_thread.cc)
target_link_libraries(test_thread serverLib)

add_executable(test_fiber tests/test_fiber.cc)
target_link_libraries(test_fiber serverLib)

 add_executable(test_scheduler tests/test_scheduler.cc)
 target_link_libraries(test_scheduler serverLib)

add_executable(test_iomanager tests/test_iomanager.cc)
target_link_libraries(test_iomanager serverLib)


add_executable(test_hook tests/test_hook.cc)
target_link_libraries(test_hook serverLib)